package com.moinut.studentattendancemanager.model.dao.impl;

import com.moinut.studentattendancemanager.model.dao.IFacultyDAO;

import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * @author MOILING
 */
public class FacultyDAOImpl extends BaseDAOImpl implements IFacultyDAO {

    public FacultyDAOImpl(Connection connection) {
        super(connection);
    }

    @Override
    public List<String> getAllFacultyName() throws Exception {
        List<String> names = new ArrayList<>();
        String sql = "SELECT faculty_name FROM facultyinfo";
        preparedStatement = connection.prepareStatement(sql);
        ResultSet resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            names.add(resultSet.getString(1));
        }
        if (this.preparedStatement != null) {
            this.preparedStatement.close();
        }
        return names;
    }
}
